/////////////////////////////////////////////////////////////////////////////
// Name:        ax_ui_adaptation_standard.h
// Purpose:     Voicing adaptation for standard wxWidgets controls
// Author:      Julian Smart
// Modified by:
// Created:     2009-03-20
// RCS-ID:
// Copyright:   (c) Julian Smart
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _AX_UI_ADAPTATION_STANDARD_H_
#define _AX_UI_ADAPTATION_STANDARD_H_

#include "wx/timer.h"

#include "ax/ax_ui_adaptation.h"

/**
    @class AxStandardControlsVoiceAdaptationHandler

    Knows how to creates suitable event handler objects for various controls classes.

    @category{ax}
 */

class AxStandardControlsVoiceAdaptationHandler: public AxVoiceAdaptationHandler
{
    DECLARE_DYNAMIC_CLASS( AxStandardControlsVoiceAdaptationHandler )

public:
    AxStandardControlsVoiceAdaptationHandler() {}

    /// Override to indicate if this kind of window can be handled by this object.
    virtual bool CanHandleWindow(wxWindow* win);

    /// Override to create the event handler (but not push it onto the event stack)
    virtual AxAdapter* CreateEventHandler(wxWindow* win);

    /// Override to adapt e.g. a composite control. Returns an array of the identifiers
    /// of the adapted windows.
    virtual bool Adapt(wxWindow* window, AxSpeech* speech, wxShortcutManager* shortcuts, wxArrayInt& ids);

    /// Override to unadapt e.g. a composite control. Removes the id from ids once unadapted.
    virtual bool Unadapt(wxWindow* window, wxArrayInt& ids);

    /// Override to prevent recursive adaptation, e.g. into a composite.
    virtual bool CanRecursivelyAdapt(wxWindow* window) const;
};

/**
    @class AxDialogAdapter

    An event handler that processes events from a wxDialog
    and speaks, as appropriate.

    @category{ax}
 */

class wxDialog;

class AxDialogAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxDialogAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxDialogAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel();

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnInitDialog(wxInitDialogEvent& event);

    wxDialog* GetDialog() const;

protected:
};

/**
    @class AxPanelAdapter

    An adapter for a wxPanel. This doesn't speak anything, but
    it allows other adapter functionality to work for the panel,
    such as responding to text size and colour changes.

    @category{ax}
 */

class AxPanelAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxPanelAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxPanelAdapter() {}

// Overrides

    /// Called after children have been updated
    virtual bool PostUpdateAppearance(int hints);

    /// Override to return the name of the control.
    virtual wxString GetName() { return _("panel"); }

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel WXUNUSED(level)) { return wxEmptyString; }

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return wxEmptyString; }

    /// Get content
    virtual wxString GetContent(AxContentLevel WXUNUSED(level)) { return wxEmptyString; }

    /// Override and return false from this function if the control shouldn't
    /// be voiced.
    virtual bool IsVoiced() const { return false; }

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    wxPanel* GetPanel() const;

protected:
};

/**
    @class AxFrameAdapter

    An event handler that processes events from a wxFrame
    and speaks, as appropriate.

    @category{ax}
 */

class wxFrame;

class AxFrameAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxFrameAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxFrameAdapter() { Init(); }
    ~AxFrameAdapter();

    void Init();

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel();

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnMenuOpen(wxMenuEvent& event);
    void OnMenuClose(wxMenuEvent& event);
    void OnMenuHighlight(wxMenuEvent& event);
    void OnMenuSelect(wxCommandEvent& event);

    void OnTimeOut(wxTimerEvent& event);

    wxFrame* GetFrame() const;

protected:
    // A menu open speech event is pending if not -1. Value is menu position.
    int m_openMenuPending;

    // For scheduling menu open speech event
    wxTimer m_timer;
};

/**
    @class AxStaticTextAdapter

    An adapter for a wxStaticText. This doesn't speak anything, but
    it allows other adapter functionality to work,
    such as responding to text size and colour changes.

    @category{ax}
 */

class AxStaticTextAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxStaticTextAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxStaticTextAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName() { return _("static text"); }

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel WXUNUSED(level)) { return wxEmptyString; }

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return GetMainControl()->GetLabel(); }

    /// Get content
    virtual wxString GetContent(AxContentLevel WXUNUSED(level)) { return wxEmptyString; }

    /// Override and return false from this function if the control shouldn't
    /// be voiced.
    virtual bool IsVoiced() const { return false; }

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    wxStaticText* GetStaticText() const;

protected:
};

/**
    @class AxStaticBoxAdapter

    An adapter for a wxStaticBox. This doesn't speak anything, but
    it allows other adapter functionality to work,
    such as responding to text size and colour changes.

    @category{ax}
 */

class AxStaticBoxAdapter: public AxStaticTextAdapter
{
    DECLARE_DYNAMIC_CLASS( AxStaticBoxAdapter )

public:
// Constructors

    AxStaticBoxAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName() { return _("static box"); }

protected:
};

/**
    @class AxButtonAdapter

    An event handler that processes events from a wxButton
    and speaks, as appropriate.

    @category{ax}
 */

class wxButton;
class wxBitmapButton;

class AxButtonAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxButtonAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxButtonAdapter(const wxString& alternateLabel = wxEmptyString) { SetAlternateLabel(alternateLabel); }

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return GetControlLabel(); }

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Update the appearance - text size, background, etc.
    virtual bool UpdateAppearance(int hints);

// New functions

    void OnCommand(wxCommandEvent& event);

    wxButton* GetButton() const;
    wxBitmapButton* GetBitmapButton() const;

protected:
};

/**
    @class AxButtonAdapter

    An event handler that processes events from a wxButton
    and speaks, as appropriate.

    @category{ax}
 */

class wxToggleButton;

class AxToggleButtonAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxToggleButtonAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxToggleButtonAdapter(const wxString& alternateLabel = wxEmptyString) { SetAlternateLabel(alternateLabel); }

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return GetControlLabel(); }

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxCommandEvent& event);

    wxToggleButton* GetToggleButton() const;

protected:
};

/**
    @class AxCheckBoxAdapter

    An event handler that processes events from a wxButton
    and speaks, as appropriate.

    @category{ax}
 */

class wxCheckBox;
class AxCheckBoxAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxCheckBoxAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxCheckBoxAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return GetControlLabel(); }

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnCommand(wxCommandEvent& event);

    wxCheckBox* GetCheckBox() const;

protected:
};

/**
    @class AxRadioButtonAdapter

    An event handler that processes events from a wxRadioButton
    and speaks, as appropriate.

    @category{ax}
 */

class wxRadioButton;

class AxRadioButtonAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxRadioButtonAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxRadioButtonAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Override to return the label for the control.
    virtual wxString GetLabel() { return GetControlLabel(); }

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnCommand(wxCommandEvent& event);

    wxRadioButton* GetRadioButton() const;

protected:
};

/**
    @class AxListBoxAdapter

    An event handler that processes events from a wxListBox
    and speaks, as appropriate.

    @category{ax}
 */

class wxListBox;
class wxCheckListBox;

class AxListBoxAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxListBoxAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxListBoxAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxCommandEvent& event);

    wxListBox* GetListBox() const;
    wxCheckListBox* GetCheckListBox() const;

protected:
};

/**
    @class AxListCtrlAdapter

    An event handler that processes events from a wxListCtrl
    and speaks, as appropriate.

    @category{ax}
 */

class wxListCtrl;
class wxListEvent;

class AxListCtrlAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxListCtrlAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxListCtrlAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnSelection(wxListEvent& event);

    wxListCtrl* GetListCtrl() const;

protected:
};

/**
    @class AxTreeCtrlAdapter

    An event handler that processes events from a wxTreeCtrl
    and speaks, as appropriate.

    @category{ax}
 */

class wxTreeCtrl;
class wxTreeEvent;

class AxTreeCtrlAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxTreeCtrlAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxTreeCtrlAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnSelection(wxTreeEvent& event);

    wxTreeCtrl* GetTreeCtrl() const;

protected:
};

/**
    @class AxComboBoxAdapter

    An event handler that processes events from a wxComboBox
    and speaks, as appropriate.

    @category{ax}
 */

class wxComboBox;

class AxComboBoxAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxComboBoxAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxComboBoxAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxCommandEvent& event);
    void OnText(wxCommandEvent& event);

    wxComboBox* GetComboBox() const;

protected:
};

/**
    @class AxChoiceAdapter

    An event handler that processes events from a wxChoice
    and speaks, as appropriate.

    @category{ax}
 */

class wxChoice;

class AxChoiceAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxChoiceAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxChoiceAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxCommandEvent& event);

    wxChoice* GetChoice() const;

protected:
};

/**
    @class AxSpinCtrlAdapter

    An event handler that processes events from a wxSpinCtrl
    and speaks, as appropriate.

    @category{ax}
 */

class wxSpinCtrl;
class wxSpinEvent;

class AxSpinCtrlAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxSpinCtrlAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxSpinCtrlAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxSpinEvent& event);

    wxSpinCtrl* GetSpinCtrl() const;

protected:
};

/**
    @class AxSliderAdapter

    An event handler that processes events from a wxSlider
    and speaks, as appropriate.

    @category{ax}
 */

class wxSlider;

class AxSliderAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxSliderAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxSliderAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    void OnCommand(wxCommandEvent& event);

    wxSlider* GetSlider() const;

protected:
};

/**
    @class AxHtmlWindowAdapter

    An event handler that processes events from a wxHtmlWindow
    and speaks, as appropriate.

    @category{ax}
 */

class wxHtmlWindow;

class AxHtmlWindowAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxHtmlWindowAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxHtmlWindowAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

// New functions

    wxHtmlWindow* GetHtmlWindow() const;

protected:
};

/**
    @class AxNotebookAdapter

    An event handler that processes events from a wxNotebook
    and speaks, as appropriate.

    @category{ax}
 */

class wxNotebook;
class wxNotebookEvent;
class wxChoicebook;
class wxChoicebookEvent;
class wxListbook;
class wxListbookEvent;
class wxTreebook;
class wxTreebookEvent;
class wxBookCtrlBase;

class AxNotebookAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxNotebookAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxNotebookAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnNotebookPageChanged(wxNotebookEvent& event);
    void OnChoicebookPageChanged(wxChoicebookEvent& event);
    void OnListbookPageChanged(wxListbookEvent& event);
    void OnTreebookPageChanged(wxTreebookEvent& event);

    void OnPageChanged(int sel);

    wxBookCtrlBase* GetBookCtrl() const;
    wxNotebook* GetNotebook() const;
    wxChoicebook* GetChoicebook() const;
    wxListbook* GetListbook() const;
    wxTreebook* GetTreebook() const;

protected:
};

/**
    @class AxHyperlinkCtrlAdapter

    An event handler that processes events from a wxHyperlinkCtrl
    and speaks, as appropriate.

    @category{ax}
 */

class wxHyperlinkCtrl;
class wxHyperlinkEvent;

class AxHyperlinkCtrlAdapter: public AxAdapter
{
    DECLARE_DYNAMIC_CLASS( AxHyperlinkCtrlAdapter )
    DECLARE_EVENT_TABLE()

public:
// Constructors

    AxHyperlinkCtrlAdapter() {}

// Overrides

    /// Override to return the name of the control.
    virtual wxString GetName();

    /// Override to return text representing the state of the control,
    /// for example the current value.
    virtual wxString GetStateText(AxContentLevel level);

    /// Get content
    virtual wxString GetContent(AxContentLevel level);

    /// Apply window colours
    virtual bool ApplyWindowColours();

// New functions

    void OnCommand(wxHyperlinkEvent& event);

    wxHyperlinkCtrl* GetHyperlinkCtrl() const;

protected:
};


#endif
    // _AX_UI_ADAPTATION_STANDARD_H_
